import 'dart:convert';
import 'dart:io';

import 'package:android_intent_plus/android_intent.dart';
import 'package:bruno/bruno.dart';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart';
import 'package:flutter_bmflocation/flutter_bmflocation.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:geolocator/geolocator.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:sharesdk_plugin/sharesdk_defines.dart';
import 'package:sharesdk_plugin/sharesdk_interface.dart';
import 'package:sharesdk_plugin/sharesdk_map.dart';

import 'package:sph_driver/FindGoods/ComplaintGoods.dart';
import 'package:sph_driver/FindGoods/DrivingRouteView.dart';
import 'package:sph_driver/FindGoods/PaymentOfFeesView.dart';
import 'package:url_launcher/url_launcher.dart';

import '../AppConfig/Config.dart';
import '../AppConfig/LocalStorage.dart';
import '../AppConfig/RouteAct.dart';
import '../AppConfig/ShowDialog.dart';
import '../AppConfig/StringEncapsulation.dart';
import '../Main/CustomerService/CustomerServiceMain.dart';
import '../Main/InformationView.dart';
import '../Order/WaybillDetails/ShipperIntroduction.dart';
import '../http/NoLoadingGetApi.dart';
import '../http/NoLoadingPostApi.dart';
import '../http/api.dart';
import '../l10n/messages.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:platform/platform.dart';

class SourceDetails extends StatefulWidget {
  const SourceDetails({super.key, required this.dataMap});
  final Map dataMap;
  @override
  State<SourceDetails> createState() => _SourceDetailsState();
}

class _SourceDetailsState extends State<SourceDetails> {
  String dintanceStr="1000";
  String gotodisStr="1000";
  late Position _currentPosition;
  BaiduLocation _loationResult = BaiduLocation();
  double nowLat=0;
  double nowLng=0;
  Map dataMap={};
  final LocationFlutterPlugin _myLocPlugin = LocationFlutterPlugin();
  bool _suc = false;
  _makePhoneCall(String phoneNumber) async {
    if (LocalPlatform().isAndroid) {
      var status = await Permission.phone.status;
      if (status.isGranted) {
        // 权限已被授予
        // callPhone();
        final AndroidIntent intent = AndroidIntent(
          action: 'android.intent.action.CALL',
          data: Uri.encodeFull('tel:$phoneNumber'),
        );
        await intent.launch();
      } else if (status.isDenied) {
        showCallPhoneFirstDialog(context);
        // 权限被拒绝，但用户可以再次授权
        status = await Permission.phone.request();
        if (status.isGranted) {
          // 用户同意了权限
          // callPhone();
          final AndroidIntent intent = AndroidIntent(
            action: 'android.intent.action.CALL',
            data: Uri.encodeFull('tel:$phoneNumber'),
          );
          await intent.launch();
        } else {
          showCallPhoneDialog(context);
          // 用户拒绝权限，无法发起电话
          // 可以在此处展示信息提示用户需要权限
        }
      } else if (status.isPermanentlyDenied) {
        // 权限被永久拒绝，需要用户手动开启权限
        showCallPhoneDialog(context);
      }

    }else{

      final url =Uri.parse('tel:$phoneNumber');
      if (await canLaunchUrl(url)) {
        await launchUrl(url);
      } else {
        throw '无法拨打电话：$url';
      }
    }
  }
  String convertMetersToKilometers(String metersString) {
    // 解析字符串为整数
    int meters = int.parse(metersString);

    // 转换为千米
    double kilometers = meters / 1000.0;

    // 格式化并返回字符串
    return kilometers.toStringAsFixed(2); // 返回保留两位小数的字符串
  }
  //增加联系记录
Future<void> addDriverCantact() async {

  String? drvId =await UserIdManager.getUserID();

    NoLoadingApiManager.postData(
      context,
      'api/goods/goods/contact/driverAdd',
      {
        "goodsId": dataMap['id'],
        "shipperId": dataMap['shipperId'],
      },
          (responseData)  {
            _makePhoneCall(dataMap['phoneNum']);
      },
    );



}
void preAdd(){
  NoLoadingApiManager.postData(
    context,
    'api/waybill/driver/waybill/preAddByDriver',
    {
      "goodsId": dataMap['id'],
    },
        (responseData)  {
      Navigator.push(context, FadeRoute(page: PaymentOfFeesView(
        dataMap: responseData['data'], dintanceStr: dintanceStr, needPay:responseData['data']['needPay'], isDriverAdd: true, id:dataMap['id'],
      )));
    },
  );
}
//去装货地
  void onOpenBaiduNaviNative(BMFNaviType naviType) async {


    // 我的位置
    BMFCoordinate coordinate1 = BMFCoordinate(double.parse(dataMap['loadPlaceInfo'][0]['latitude']), double.parse(dataMap['loadPlaceInfo'][0]['longitude']));
    String startName = "我的位置";
    // 百度大厦坐标
    String endName = dataMap['unloadPlaceInfo'][0]['detailedAddress'];
    BMFCoordinate coordinate2 = BMFCoordinate(double.parse(dataMap['unloadPlaceInfo'][0]['latitude']), double.parse(dataMap['unloadPlaceInfo'][0]['longitude']));

    BMFOpenNaviOption naviOption = BMFOpenNaviOption(
        startCoord: coordinate1,
        endCoord: coordinate2,
        startName: startName,
        endName: endName,
        naviType: naviType,
        appScheme: 'baidumapsdk://mapsdk.baidu.com', // 指定返回自定义scheme
        appName: 'baidumap', // 应用名称
        isSupportWeb:
        false); // 调起百度地图客户端驾车导航失败后（步行、骑行导航设置该参数无效），是否支持调起web地图，默认：true

    BMFOpenErrorCode? flag = await BMFOpenMapUtils.openBaiduMapNavi(naviOption);
    print('open - navi - errorCode = $flag');
  }
  void onOpenBaiduMapRoute(BMFOpenRouteType routeType) async {
    String? lat= await LatitudeManager.getLatitude();
    String? lon= await LongitudeManager.getLongitude();
    // BMFCoordinate startCoord = BMFCoordinate(double.parse(dataMap['loadPlaceInfo'][0]['latitude']), double.parse(dataMap['loadPlaceInfo'][0]['longitude']));

     BMFCoordinate  startCoord = BMFCoordinate(double.parse(lat!) , double.parse(lon!));

    // String startName = dataMap['loadPlaceInfo'][0]['detailedAddress'];
    String startName ="我的位置";
    String endName =dataMap['loadPlaceInfo'][0]['address'];
    BMFCoordinate endCoord = BMFCoordinate(dataMap['loadPlaceInfo'][0]['latitude'], dataMap['loadPlaceInfo'][0]['longitude']);
    BMFOpenRouteOption routeOption = BMFOpenRouteOption(
        startCoord: startCoord,
        startName: startName,
        endCoord: endCoord,
        endName: endName,
        routeType: routeType,
        appScheme: 'baidumapsdk://mapsdk.baidu.com', // 指定返回自定义scheme
        isSupportWeb: true);
    BMFOpenErrorCode? flag =
    await BMFOpenMapUtils.openBaiduMapRoute(routeOption);
    print('open - route - errorCode = $flag');
  }

  //获取到装货地距离
  Future<void> getGotoDisAction() async {
    String? lat= await LatitudeManager.getLatitude();
    String? lon= await LongitudeManager.getLongitude();
    String? token = await TokenManager.getToken();
    dio.interceptors.add(InterceptorsWrapper(
        onRequest: (options, handler) {
          options.headers["satoken"] = token;
          return handler.next(options);
        }
    ));
    dio.get<String>("https://api.map.baidu.com/directionlite/v1/driving?origin=$lat,$lon&destination=${dataMap['loadPlaceInfo'][0]['latitude']},${dataMap['loadPlaceInfo'][0]['longitude']}&ak=Pb9qx5M4d02snVGSQaEqGVpqybA18AS8")
        .then((r) {
      setState(() {
        print(r);
        Map<String, dynamic> jsonMap = json.decode(r.toString());
        // 获取code和data
        String code = jsonMap['status'].toString();
        if (code == "0") {
          setState(() {
            List list =jsonMap['result']['routes'];
            gotodisStr = list[0]['distance'].toString();
            print("距离:$gotodisStr");
          });
        } else {
          // BrnToast.show(jsonMap['message'], context);
        }
        // 打印结果
        print('Code: $code');
      });
    }).catchError((error) {
      print(error);
    });

  }
  //获取运输距离
  Future<void> getDistanceAction() async {
    print(dataMap['unloadPlaceInfo']);
    String? token = await TokenManager.getToken();
    dio.interceptors.add(InterceptorsWrapper(
        onRequest: (options, handler) {
          options.headers["satoken"] = token;
          return handler.next(options);
        }
    ));
    dio.get<String>("https://api.map.baidu.com/directionlite/v1/driving?origin=${dataMap['unloadPlaceInfo'][0]['latitude'].toString()},${dataMap['unloadPlaceInfo'][0]['longitude'].toString()}&destination=${dataMap['loadPlaceInfo'][0]['latitude'].toString()},${dataMap['loadPlaceInfo'][0]['longitude'].toString()}&ak=Pb9qx5M4d02snVGSQaEqGVpqybA18AS8")
        .then((r) {
      setState(() {
        print(r);
        Map<String, dynamic> jsonMap = json.decode(r.toString());
        // 获取code和data
        String code = jsonMap['status'].toString();
        if (code == "0") {
          setState(() {
            List list =jsonMap['result']['routes'];
            dintanceStr = list[0]['distance'].toString();
            print("距离:$dintanceStr");
          });
        } else {
          // BrnToast.show(jsonMap['message'], context);
        }
        // 打印结果
        print('Code: $code');
      });
    }).catchError((error) {
      print(error);
    });

  }
  void _locationAction() async {
    /// 设置android端和ios端定位参数
    /// android 端设置定位参数
    /// ios 端设置定位参数

    var status = await Permission.location.status;
    if (!status.isGranted) {
      await Permission.location.request();
    }

    Map iosMap = initIOSOptions().getMap();
    Map androidMap = initAndroidOptions().getMap();

    _suc = await _myLocPlugin.prepareLoc(androidMap, iosMap);
    print('设置定位参数：$iosMap');
  }
  /// 设置地图参数
  BaiduLocationAndroidOption initAndroidOptions() {
    BaiduLocationAndroidOption options = BaiduLocationAndroidOption(
        coorType: 'bd09ll',
        locationMode: BMFLocationMode.hightAccuracy,
        isNeedAddress: true,
        isNeedAltitude: true,
        isNeedLocationPoiList: true,
        isNeedNewVersionRgc: true,
        isNeedLocationDescribe: true,
        openGps: true,
        locationPurpose: BMFLocationPurpose.sport,
        coordType: BMFLocationCoordType.bd09ll);
    return options;
  }

  BaiduLocationIOSOption initIOSOptions() {
    BaiduLocationIOSOption options = BaiduLocationIOSOption(
        coordType: BMFLocationCoordType.bd09ll,
        BMKLocationCoordinateType: 'BMKLocationCoordinateTypeBMK09LL',
        desiredAccuracy: BMFDesiredAccuracy.best);
    return options;
  }
  /// 启动定位
  Future<void> _startLocation() async {
    if (LocalPlatform().isIOS) {
      _myLocPlugin.singleLocationCallback(callback: (BaiduLocation result) {
        setState(() {
          _loationResult = result;
          nowLat=_loationResult.latitude!;
          nowLng=_loationResult.longitude!;

          getGotoDisAction();
        });
      });

    } else if (LocalPlatform().isAndroid) {
      _suc = await _myLocPlugin.startLocation();
      ///接受定位回调
      _myLocPlugin.seriesLocationCallback(callback: (BaiduLocation result) {
        setState(() {
          _loationResult = result;
          nowLat=_loationResult.latitude!;
          nowLng=_loationResult.longitude!;

          _myLocPlugin.stopLocation();
          getGotoDisAction();
        });
      });
    }

  }
  void  getDetailAction()async{
    String? token = await TokenManager.getToken();
    dio.interceptors.add(InterceptorsWrapper(
        onRequest: (options, handler) {
          options.headers["satoken"] = token;
          return handler.next(options);
        }
    ));
    dio.get<String>(MyServiceUrl.header+ "api/goods/goods/driverGoodsDetail?id=${widget.dataMap['id']}")
        .then((r) {
      setState(() {
        print(r);
        Map<String, dynamic> jsonMap = json.decode(r.toString());
        // 获取code和data
        String code = jsonMap['code'].toString();
        if (code == "200") {
          setState(() {
            dataMap = jsonMap['data'];
            _startLocation();
            getDistanceAction();
            // getGotoDisAction();
          });
        }else if(code == "500100031"||code == "500100032"||code == "500100033"){
          showDialog(
            barrierDismissible: false,
            context: context,
            builder: (BuildContext context) {
              return BrnDialog(

                titleText: jsonMap['msg'],
                messageText:code =="500100032"?"请先完成身份、驾驶证、行驶证认证":code =="500100033"?"请先完成身份、驾驶证、行驶证、道路运输证、从业资格认证":"请先完成实名认证",
                actionsWidget: [
                  TextButton(
                    onPressed: () async{
                      Navigator.pop(context);
                    final result=await  Navigator.push( context, FadeRoute(page:InformationView(dataMap: {}, isAdd: true,)));
                    if(result!=null){
                      getDetailAction();
                    }
                    },
                    child: Text("前往认证",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                  ),
                ],
              );
            },
          );
        } else {
          BrnToast.show(jsonMap['msg'].toString(), context);
          Navigator.pop(context);
        }
        // 打印结果

      });
    }).catchError((error) {
      BrnToast.show(error.toString(), context);
    });
    // NoLoadinggetApiManager.getData(
    //   context,
    //   "api/goods/goods/driverGoodsDetail",
    //   {"id":widget.dataMap['id']},
    //       (responseData)  {
    //     setState(() {
    //       dataMap=responseData['data'];
    //       _startLocation();
    //       getDistanceAction();
    //       // getGotoDisAction();
    //     });
    //
    //   },
    // );
  }
@override
  void initState() {
    // TODO: implement initState
    super.initState();
    _locationAction();
    getDetailAction();
    // _startLocation();
    //

    //
    // getDistanceAction();

  }
  @override
  Widget build(BuildContext context) {
    var messages = AppLocalizations.of(context)!;
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
      appBar: AppBar(
        leading: IconButton(icon: Icon(Icons.arrow_back_ios,color: Colors.black,),onPressed: (){Navigator.pop(context);},),
        centerTitle: true,
        backgroundColor: Colors.white,
        title: Text("货源详情",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w300),),
        actions: [

          Container(
            width: 20.w,
            child:   BrnIconButton(
                name: '客服',
                style: TextStyle(
                  fontSize: 8.sp,
                  color: Colors.black,
                ),
                direction: Direction.bottom,
                padding: 0,
                iconHeight: 16.h,
                iconWidth: 16.w,
                iconWidget: Image.asset("lib/Images/PersonCenter/客服icon.png"),
                onTap: () {
                  Navigator.push( context, FadeRoute(page:CustomerServiceMain()));
                }),
          ),
          SizedBox(width:8.w ,),
          Container(
            width: 20.w,
            child:   BrnIconButton(
                name: '投诉',
                style: TextStyle(
                  fontSize: 8.sp,
                  color: Colors.black,
                ),
                direction: Direction.bottom,
                padding: 0,
                iconHeight: 16.h,
                iconWidth: 16.w,
                iconWidget: Image.asset("lib/Images/OrderList/货源详情投诉icon.png"),
                onTap: () {
                  Navigator.push( context, FadeRoute(page:ComplaintGoods(dataMap:dataMap)));
                }),
          ),
          SizedBox(width:8.w ,),
          // Container(
          //   width: 20.w,
          //   child:   BrnIconButton(
          //       name: '分享',
          //       style: TextStyle(
          //         fontSize: 8.sp,
          //         color: Colors.black,
          //       ),
          //       direction: Direction.bottom,
          //       padding: 0,
          //       iconHeight: 16.h,
          //       iconWidth: 16.w,
          //       iconWidget: Image.asset("lib/Images/OrderList/货源详情分享icon.png",),
          //       onTap: () {
          //         showModalBottomSheet(
          //           context: context,
          //           builder: (BuildContext context) {
          //             return Container(
          //               height: 150.h,
          //               padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 15.h,bottom: 30.h),
          //               decoration: BoxDecoration(
          //                   color: Colors.white,
          //                   borderRadius: BorderRadius.all(Radius.circular(10))),
          //               child: Column(
          //                 children: [
          //                   Row(
          //                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
          //                     children: [
          //                     Text("分享到",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
          //                       GestureDetector(
          //                         child: Icon(Icons.close,color: MyColors.textColor,size: 25,),
          //                         onTap: (){
          //                           Navigator.pop(context);
          //                         },
          //                       ),
          //                     ],
          //                   ),
          //                   Divider(height: 10.h,color: MyColors.backgreyColor,),
          //                   Row(
          //                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
          //                     children: [
          //                       SizedBox(width: 40.w,),
          //                       BrnIconButton(
          //                           name: "微信",
          //                           style: TextStyle(
          //                             fontSize: 13.sp,
          //                             color: Colors.black,
          //                           ),
          //                           direction: Direction.bottom,
          //                           padding: 4.h,
          //                           iconHeight: 40.h,
          //                           iconWidth: 40.w,
          //                           iconWidget: Image.asset("lib/Images/login/微信分享.jpg"),
          //                           onTap: () {
          //                             SSDKMap params = SSDKMap()
          //                               ..setGeneral(
          //                                   "速配货司机版",
          //                                   "货源分享",
          //                                   [
          //                                     "http://www.sph56.cn"
          //                                   ],
          //                                   "",
          //                                   "",
          //                                   "",
          //                                   "",
          //                                   "",
          //                                   "",
          //                                   "",
          //                                   SSDKContentTypes.miniProgram);
          //                             SharesdkPlugin.share(ShareSDKPlatforms.wechatSession, params,
          //                                     (SSDKResponseState state, dynamic userdata, dynamic contentEntity,
          //                                     SSDKError error) {
          //                                   BrnToast.show(error.rawData, context);
          //
          //                                 });
          //                           }),
          //                       BrnIconButton(
          //                           name: "朋友圈",
          //                           style: TextStyle(
          //                             fontSize: 13.sp,
          //                             color: Colors.black,
          //                           ),
          //                           direction: Direction.bottom,
          //                           padding: 4.h,
          //                           iconHeight: 40.h,
          //                           iconWidth: 40.w,
          //                           iconWidget: Image.asset("lib/Images/login/朋友圈.jpg"),
          //                           onTap: () {
          //                             SSDKMap params = SSDKMap()
          //                               ..setGeneral(
          //                                   "速配货司机版",
          //                                   "货源分享",
          //                                   [
          //                                     "#小程序://速配货司机版/y8qN6LSsBeNfi1u"
          //                                   ],
          //                                   "",
          //                                   "",
          //                                   "http://mob.com",
          //                                   "",
          //                                   "",
          //                                   "",
          //                                   "",
          //                                   SSDKContentTypes.miniProgram);
          //                             SharesdkPlugin.share(ShareSDKPlatforms.wechatTimeline, params,
          //                                     (SSDKResponseState state, dynamic userdata, dynamic contentEntity,
          //                                     SSDKError error) {
          //                                   BrnToast.show(error.rawData, context);
          //
          //                                 });
          //                           }),
          //                       // BrnIconButton(
          //                       //     name: "QQ",
          //                       //     style: TextStyle(
          //                       //       fontSize: 13.sp,
          //                       //       color: Colors.black,
          //                       //     ),
          //                       //     direction: Direction.bottom,
          //                       //     padding: 4.h,
          //                       //     iconHeight: 40.h,
          //                       //     iconWidth: 40.w,
          //                       //     iconWidget: Image.asset("lib/Images/login/微信分享.jpg"),
          //                       //     onTap: () {
          //                       //       SSDKMap params = SSDKMap()
          //                       //         ..setQQ(
          //                       //             "text",
          //                       //             "title",
          //                       //             "http://m.93lj.com/sharelink?mobid=ziqMNf",
          //                       //             "",
          //                       //             "",
          //                       //             "",
          //                       //             "",
          //                       //             "",
          //                       //             "http://wx4.sinaimg.cn/large/006tkBCzly1fy8hfqdoy6j30dw0dw759.jpg",
          //                       //             "",
          //                       //             "",
          //                       //             "http://m.93lj.com/sharelink?mobid=ziqMNf",
          //                       //             "",
          //                       //             "",
          //                       //             SSDKContentTypes.webpage,
          //                       //             ShareSDKPlatforms.qq);
          //                       //       SharesdkPlugin.share(ShareSDKPlatforms.qq, params, (SSDKResponseState state,
          //                       //           dynamic userdata, dynamic contentEntity, SSDKError error) {
          //                       //         BrnToast.show(error.rawData, context);
          //                       //       });
          //                       //     }),
          //                       // BrnIconButton(
          //                       //     name: "复制链接",
          //                       //     style: TextStyle(
          //                       //       fontSize: 13.sp,
          //                       //       color: Colors.black,
          //                       //     ),
          //                       //     direction: Direction.bottom,
          //                       //     padding: 4.h,
          //                       //     iconHeight: 40.h,
          //                       //     iconWidth: 40.w,
          //                       //     iconWidget: Image.asset("lib/Images/login/微信分享.jpg"),
          //                       //     onTap: () {
          //                       //     }),
          //                       SizedBox(width: 40.w,),
          //                     ],
          //                   )
          //                 ],
          //               ),
          //             );
          //           },
          //         );
          //       }),
          // ),
          // SizedBox(width:8.w ,),
        ],
      ),
      body:dataMap.isEmpty?Container(color:Colors.white,):  Column(
        children: [
      Expanded(child: ListView(
        children: [
          Container(
            height:dataMap['deposit']!="0"?165.h:143.h,
            margin: EdgeInsets.only(top: 13.h,left: 10.w,right: 10.w),
            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(Radius.circular(10))),
            child: Stack(
                children: [
                  Container(
                    padding: EdgeInsets.only(left: 10.w,right: 10.w,bottom: 10.h),
                    height: 30.h,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(10)),
                      gradient: LinearGradient(
                        begin: Alignment.topCenter,
                        end: Alignment.bottomCenter,
                        colors: [MyColors.themeColor, Color.fromRGBO(255,206,89,1)],
                      ),
                    ),
                    child:dataMap['type']==0?
                    Row(
                      children: [
                        Image.asset("lib/Images/OrderList/货源详情一口价icon.png",width: 24.w,height: 24.h,),
                        Text("一口价货源丨",style: TextStyle(color: Colors.white,fontSize: 12.sp,fontWeight: FontWeight.w600),),
                        Text("点击立即抢单，在线支付定金后可联系货主",style: TextStyle(color: Colors.white,fontSize: 11.sp),),
                      ],
                    )
                        :Row(
                      children: [

                        Image.asset("lib/Images/OrderList/货源详情电议icon.png",width: 16.w,height: 16.h,),
                        Text("电议",style: TextStyle(color: Colors.white,fontSize: 12.sp,fontWeight: FontWeight.w600),),
                        Text("抢单前建议您先联系货主",style: TextStyle(color: Colors.white,fontSize: 11.sp),),
                      ],
                    ),
                  ),
                  Positioned(
                    top:20.h,
                    // height:widget.dataMap['deposit']==0?284.h :229.h,
                    child: Container(
                      width: screenSize.width-20.w,
                      padding: EdgeInsets.only(top: 5.sp),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.all(Radius.circular(10)),
                        color: Colors.white,
                      ),
                      child: Column(
                        children: [
                          Row(
                            mainAxisAlignment: MainAxisAlignment.end,
                            children: [
                              Text(dataMap['createTime'].toString()+"发布",style: TextStyle(color: MyColors.authTipColor,fontSize: 12.sp),),
                              SizedBox(width: 10.w,),
                            ],
                          ),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            crossAxisAlignment: CrossAxisAlignment.end,
                            children: [
                              Row(
                                children: [
                                  SizedBox(width: 15.w,),
                                  Text("运费",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                                ],
                              ),

                             dataMap['type']==0?
                              Row(
                                children: [
                                  Text("¥"+(dataMap['freight']).toString(),style: TextStyle(color: Colors.black,fontSize: 20.sp,fontWeight: FontWeight.w600),),
                                  SizedBox(width: 10.w,),
                                ],
                              ):Text("电议",style: TextStyle(color: MyColors.themeColor,fontSize: 20.sp),),
                            ],
                          ),
                          Divider(height: 10.h,color: MyColors.backgreyColor,),
                          if (dataMap['deposit']!="0.00"&&dataMap['deposit']!=null&&dataMap['deposit']!="")
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Row(
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    SizedBox(width: 15.w,),
                                    Text("订金",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                                    SizedBox(width: 4.w,),
                                    BrnTagCustom.buildBorderTag(
                                      tagText: dataMap['depositType']==0? '退还':'不退还',
                                      textColor: MyColors.themeColor,
                                      borderColor: MyColors.themeColor,
                                      borderWidth: 1,
                                      fontSize: 9.sp,
                                      textPadding: EdgeInsets.only(left: 3.w,right: 3.w),
                                    )
                                  ],
                                ),
                                Row(
                                  children: [
                                    Text((dataMap['deposit']).toString()+"元",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                                    SizedBox(width: 10.w,),
                                  ],
                                )
                              ],
                            ),
                          // if ( dataMap['deposit']!=0)
                            Column(
                              children: [
                                SizedBox(height: 4.h,),
                                Container(
                                  height: 30.h,
                                  margin: EdgeInsets.only(left: 15.w,right: 10.w),
                                  padding: EdgeInsets.only(left: 6.w,right: 6.w,top:4.h,bottom: 4.h),
                                  decoration: BoxDecoration(
                                      color: Color.fromRGBO(251, 236, 228, 1),
                                      borderRadius: BorderRadius.all(Radius.circular(6))),

                                  child: Row(
                                    crossAxisAlignment: CrossAxisAlignment.start,
                                    children: [
                                      Icon(Icons.volume_up,color: MyColors.themeColor,size: 18,),
                                      SizedBox(width: 4.w,),
                                      Container(
                                        width: screenSize.width-80.w,

                                        child: RichText(
                                          softWrap: true,
                                          text: TextSpan(
                                            children: [
                                              TextSpan(
                                                text: '订金担保：订金支付到平台用于订货押金，货主收货后，将退还给您。',
                                                style: TextStyle(color:MyColors.themeColor,fontSize: 10.sp),
                                              ),
                                              TextSpan(
                                                text: dataMap['depositType']==0? '查看订金退还流程 >':'查看订金不退还流程 >',
                                                style: TextStyle(color: MyColors.blueColor,fontSize: 10.sp),
                                                recognizer: TapGestureRecognizer()
                                                  ..onTap = () {
                                                    showDialog(
                                                        context: context,
                                                        builder: (BuildContext context) {
                                                          return DespoitAlertShow(despoitType: dataMap['depositType']+1,);
                                                        }
                                                    );
                                                  },
                                              ),
                                            ],
                                          ),
                                        ),
                                      ),

                                    ],
                                  ),
                                ),
                                SizedBox(height: 4.h,),
                                Container(
                                  margin: EdgeInsets.only(left: 15.w,right: 10.w),
                                  child:   Row(
                                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                    children: [
                                      Text("技术服务费",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                                      Text((dataMap['techServiceCharge']).toString()+"元",style: TextStyle(color: MyColors.authTipColor,fontSize: 14.sp),),
                                    ],
                                  ),
                                ),
                               
                               
                                // Container(
                                //   margin: EdgeInsets.only(left: 15.w,right: 10.w),
                                //   child:   Row(
                                //     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                //     children: [
                                //       Text("保险费",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                                //       Row(
                                //         crossAxisAlignment: CrossAxisAlignment.end,
                                //         children: [
                                //           dataMap['insuranceAmountTotal']!=null?
                                //           Text(dataMap['insuranceAmountTotal'].toString()+"元",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),)
                                //           :Text("无保险费用",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                                //           SizedBox(width: 4.w,),
                                //           if( dataMap['insuranceAmountTotal']!=null)
                                //           GestureDetector(
                                //             child: Text("保费组成>",style: TextStyle(color: MyColors.authTipColor,fontSize: 12.sp),),
                                //             onTap: (){
                                //               showModalBottomSheet(context: context,
                                //               isScrollControlled:true,
                                //                   builder: (BuildContext context)
                                //               {
                                //                 return  Container(
                                //                   height: 185.h,
                                //                   padding: EdgeInsets.only(top: 10.h,left: 17.w,right: 17.w),
                                //                   decoration: BoxDecoration(
                                //                     borderRadius: BorderRadius.all(Radius.circular(10)),
                                //                     color: Colors.white,
                                //                   ),
                                //                   child: Column(
                                //                     children: [
                                //                       Row(
                                //                         mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                //                         children: [
                                //                           SizedBox(width: 20.w,),
                                //                           Text("保费组成",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w600,fontSize: 16.sp),),
                                //                           IconButton(onPressed: (){
                                //                             Navigator.pop(context);
                                //                           }, icon:Icon(Icons.close,color: MyColors.textColor,) ),
                                //                         ],
                                //                       ),
                                //                       SizedBox(height: 35.h,),
                                //                       Row(
                                //                         mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                //                         children: [
                                //                           Text("货运险",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                                //                           Text("${dataMap['goodsInsurance'][0]['insuranceAmount']}元",style: TextStyle(color:MyColors.themeColor),),
                                //                         ],
                                //                       ),
                                //                       SizedBox(height: 8.h,),
                                //                       if(dataMap['goodsInsurance'].length>1)
                                //                       Row(
                                //                         mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                //                         children: [
                                //                           Text("驾乘意外险",style: TextStyle(color: Colors.black),),
                                //                           Text("10元",style: TextStyle(color:MyColors.themeColor),),
                                //                         ],
                                //                       ),
                                //                     ],
                                //                   ),
                                //                 );
                                //
                                //               }
                                //               );
                                //             },
                                //           ),
                                //         ],
                                //       ),
                                //
                                //     ],
                                //   ),
                                // ),

                               
                                Container(

                                  decoration: BoxDecoration(
                                    borderRadius: BorderRadius.only(bottomRight:  Radius.circular(10),bottomLeft:  Radius.circular(10)),
                                    // color: Color.fromRGBO(251, 251, 251, 1),
                                  ),
                                  child: Row(
                                      children:[
                                        SizedBox(width: 10.w,),
                                        Text("需要支付费用:技术服务费",style: TextStyle(color: MyColors.authTipColor,fontSize: 10.sp),),
                                        if(dataMap['deposit']!=0)
                                          Text("、订金",style: TextStyle(color: MyColors.authTipColor,fontSize: 10.sp),),
                                        if(dataMap['insuranceAmountTotal']!=null)
                                          Text("、保费",style: TextStyle(color: MyColors.authTipColor,fontSize: 10.sp),),
                                      ]
                                  ),
                                ),
                              ],
                            ),

                        ],
                      ),

                    ),
                  ),

                ]
            ),
          ),
          SizedBox(height: 8.h,),
          Container(
            margin: EdgeInsets.only(left: 10.w,right: 10.w),
            padding: EdgeInsets.only(top: 8.h,bottom: 8.h,left: 19.w,right: 19.w),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(10)),
              color: Colors.white,
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  children: [
                    Text(dataMap['loadDay']+" "+dataMap['loadTime']+"点装货",style: TextStyle(color: Colors.black,fontSize: 13.sp),),
                    SizedBox(width: 13.w,),
                    if(dataMap['loadPlaceInfo'].length>1||dataMap['unloadPlaceInfo'].length>1)
                      BrnTagCustom(
                        backgroundColor:Color.fromRGBO(25, 137, 250, 0.2) ,
                        textColor: Color.fromRGBO(15, 64, 245, 1),
                        tagText: "多装卸",
                      ),
                    if(dataMap['loadPlaceInfo'].length==1&&dataMap['unloadPlaceInfo'].length==1)
                      BrnTagCustom(
                        backgroundColor:Color.fromRGBO(25, 137, 250, 0.2) ,
                        textColor: Color.fromRGBO(15, 64, 245, 1),
                        tagText: "一装一卸",
                      ),
                  ],
                ),

                Divider(height: 6.h,color: MyColors.backgreyColor,),
                Row(
                  children: [
                    Column(
                      children: [
                        Image.asset("lib/Images/OrderList/装icon.png",
                          width: 13.w, height: 13.h,),
                        Image.asset(
                          "lib/Images/OrderList/垂直虚线.png", width: 13.w,
                          height: 20.h,),
                        if(dataMap['loadPlaceInfo'].length == 2)
                          Column(
                            children: [
                              Image.asset(
                                "lib/Images/OrderList/装icon.png",
                                width: 13.w, height: 13.h,),
                              Image.asset(
                                "lib/Images/OrderList/垂直虚线.png",
                                width: 13.w, height:20.h,),
                            ],
                          ),
                        if( dataMap['unloadPlaceInfo'].length == 2)
                          Column(
                            children: [
                              Image.asset(
                                "lib/Images/OrderList/卸icon.png",
                                width: 13.w, height: 13.h,),
                              Image.asset(
                                "lib/Images/OrderList/垂直虚线.png",
                                width: 13.w, height: 20.h,),
                            ],
                          ),

                        Image.asset("lib/Images/OrderList/卸icon.png",
                          width: 13.w, height: 13.h,),
                      ],
                    ),
                    SizedBox(width: 8.w,),
                    Column(
                      crossAxisAlignment: CrossAxisAlignment.start,

                      children: [
                        // SizedBox(height: 8.h,),
                        Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Text(
                              dataMap["loadPlaceInfo"][0]["city"] +
                                  "-" +
                                 dataMap["loadPlaceInfo"][0]["county"],
                              style: TextStyle(
                                  color: Colors.black, fontSize: 14.sp,fontWeight: FontWeight.w600),),

                          ],
                        ),
                        Container(
                          width: screenSize.width-100.w,
                          child: Text(
                            widget.dataMap["loadPlaceInfo"][0]["address"],
                            style: TextStyle(
                                color: MyColors.textColor,overflow: TextOverflow.ellipsis,
                                fontSize: 12.sp),),
                        ),

                       
                        if(dataMap["loadPlaceInfo"].length == 2&&dataMap["loadPlaceInfo"][1]!=null)
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Row(
                                children: [
                                  Text(
                                    dataMap["loadPlaceInfo"][1]["city"] +
                                        "-" +
                                        dataMap["loadPlaceInfo"][1]["county"],
                                    style: TextStyle(color: Colors.black,
                                        fontSize: 14.sp,fontWeight: FontWeight.w600),),

                                ],
                              ),
                              Container(
                                width: screenSize.width-100.w,
                                child: Text(
                                  widget.dataMap["loadPlaceInfo"][1]["address"],
                                  style: TextStyle(
                                      color: MyColors.textColor,overflow: TextOverflow.ellipsis,
                                      fontSize: 12.sp),),
                              ),
                            ],
                          ),

                        Row(
                          children: [
                            Text(
                              dataMap["unloadPlaceInfo"][0]["city"] +
                                  "-" +
                                  dataMap["unloadPlaceInfo"][0]["county"],
                              style: TextStyle(
                                  color: Colors.black, fontSize: 14.sp,fontWeight: FontWeight.w600),),

                          ],

                        ),
                        Container(
                          width: screenSize.width-100.w,
                          child: Text(
                            widget.dataMap["unloadPlaceInfo"][0]["address"],
                            style: TextStyle(
                                color: MyColors.textColor,overflow: TextOverflow.ellipsis,
                                fontSize: 12.sp),),
                        ),

                        if(dataMap["unloadPlaceInfo"].length == 2&&dataMap["unloadPlaceInfo"][1]!=null)
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              SizedBox(height: 8.h,),
                              Row(
                                children: [
                                  Text(
                                    dataMap["unloadPlaceInfo"][1]["city"] +
                                        " " +
                                        dataMap["unloadPlaceInfo"][1]["county"],
                                    style: TextStyle(color: Colors.black,
                                        fontSize: 14.sp),),

                                ],
                              ),

                              Container(
                                width: screenSize.width-100.w,
                                child: Text(
                                  widget.dataMap["unloadPlaceInfo"][1]["address"],
                                  style: TextStyle(
                                      color: MyColors.textColor,overflow: TextOverflow.ellipsis,
                                      fontSize: 12.sp),),
                              ),
                            ],
                          ),
                      ],

                    ),
                  ],
                ),
                SizedBox(height: 4.h,),
                Container(
                  padding:EdgeInsets.only(left: 16.w,right: 11.w,bottom: 4.h,top: 4.h) ,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(10)),
                    color: Color.fromRGBO(239, 239, 239, 1),
                  ),
                  child:Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Column(
                        children: [
                          Text(gotodisStr!="1000"?"${convertMetersToKilometers(gotodisStr)}Km":"--",style: TextStyle(color: Colors.black,fontSize: 12.sp),),
                          Text("距装货地约",style: TextStyle(color:Color.fromRGBO(108, 108, 108, 1) ,fontSize: 10.sp),),
                        ],
                      ),
                      GestureDetector(
                        child:  Column(
                          children: [
                            Icon(Icons.near_me,color: MyColors.blueColor,size: 20,),
                            Text("去装货地",style: TextStyle(color:MyColors.blueColor ,fontSize: 11.sp),),
                          ],
                        ),
                        onTap: (){
                          onOpenBaiduMapRoute(BMFOpenRouteType.TruckRoute);
                          // onOpenBaiduNaviNative(BMFNaviType.TruckNavi);
                        },
                      ),

                      Container(
                        width: 1.w,
                        height: 18.h,
                        color:Color.fromRGBO(154, 154, 154, 1) ,
                      ),
                      Column(
                        children: [
                          Text("${convertMetersToKilometers(dintanceStr)}Km",style: TextStyle(color: Colors.black),),
                           // Text((dataMap['distance']/1000).toStringAsFixed(2)+"Km",style: TextStyle(color: Colors.black),),
                          Text("预估运输里程",style: TextStyle(color:Color.fromRGBO(108, 108, 108, 1) ,fontSize: 11.sp),),
                        ],
                      ),
                      GestureDetector(
                        child:Column(
                          children: [
                            Image.asset("lib/Images/OrderList/货源详情查看路线icon.png",width: 18.w,height: 14.h,),
                            Text("查看线路",style: TextStyle(color:MyColors.themeColor ,fontSize: 11.sp),),
                          ],
                        ),
                        onTap: (){
                          Navigator.push( context, FadeRoute(page:DrivingRouteView(
                            dataMap: dataMap,
                          )));

                        },
                      )
                    ],
                  ) ,
                ),
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),
            padding: EdgeInsets.only(left: 17.w,right: 7.w,top: 9.h,bottom: 9.h),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight:Radius.circular(10) ),
              color: Colors.white,
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text("车货信息",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                Divider(height: 6.h,color: MyColors.backgreyColor,),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("车辆",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                    Row(
                      children: [
                        dataMap["vehicleLength"].contains(",")?
                        Text( dataMap["vehicleLength"].replaceAll(",", "米/")+"米",style: TextStyle(color: Colors.black, fontSize: 13.sp),):
                        Text( dataMap["vehicleLength"]+"米",style: TextStyle(color: Colors.black, fontSize: 13.sp),),
                        dataMap["vehicleLength"].contains(",")?
                        Text("丨"+dataMap["vehicleModel"].replaceAll(",", "/"),style: TextStyle(color: Colors.black, fontSize: 13.sp),)
                            : Text(","+dataMap["vehicleModel"],style: TextStyle(color: Colors.black, fontSize: 13.sp),),
                      ],
                    ),
                  
                    // Text(dataMap["vehicleModel"], style: TextStyle(color: Colors.black,fontSize: 14.sp)),
                    // Text(dataMap["vehicleLength"].replaceAll('[', '').replaceAll(']', '米').replaceAll('"', '').replaceAll(',', '米/')
                    //     + " "+dataMap["vehicleModel"].replaceAll('[', '').replaceAll(']', '').replaceAll('"', '').replaceAll(',', '/'),
                    // style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                  ],
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("货物",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                    Row(
                      children: [
                        Text( dataMap["cargoInfo"][0]['cargoName'],style: TextStyle(color: Colors.black,fontSize: 13.sp),),
                        if(dataMap["cargoInfo"][0]['cargoWeight']!=null)
                          Text( dataMap["cargoInfo"][0]['cargoWeight'].toString()+"吨",style: TextStyle(color: Colors.black,fontSize: 13.sp)),
                        if(dataMap["cargoInfo"][0]['cargoVolume']!=null) 
                          Text( dataMap["cargoInfo"][0]['cargoVolume'].toString()+"方",style: TextStyle(color: Colors.black,fontSize: 13.sp)),
                      ],
                    )

                   
                    ],  
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("备注",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                    Container(
                      width:screenSize.width -100.w,
                      child:
                          Text(dataMap['remark'],
                            // maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(color: Colors.black,fontSize: 13.sp),),
                    ),

                  ],
                ),
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(left: 10.w,right: 10.w),
            padding: EdgeInsets.only(left:19.w,right: 19.w,bottom:4.h,top: 4.h),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.only(bottomLeft: Radius.circular(10),bottomRight:Radius.circular(10) ),
              color: Color.fromRGBO(251, 251, 251, 1),
            ),
            child:GestureDetector(
              child: Text("装货前请核查货物种类，勿承运危险违禁货物，查看详情 >>",style: TextStyle(color: Color.fromRGBO(156, 156, 156, 1),fontSize: 10.sp),),
            onTap: (){
              showDialog(
                  context: context,
                  builder: (BuildContext context) {
                    return CarGoodsMessageTips();
                  }
              );
            },
            ),

          ),
          GestureDetector(
            child: Container(
                margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),
                padding: EdgeInsets.only(left:20.w,right: 19.w,bottom:8.h,top: 8.h),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(Radius.circular(10) ),
                  color: Colors.white,
                ),
                child: Column(
                  children: [
                    Row(
                      children: [
                        Container(
                          decoration: BoxDecoration(
                              color: Colors.white,
                              borderRadius: BorderRadius.all(Radius.circular(10))),
                          child: ClipRRect(
                            borderRadius: BorderRadius.all(Radius.circular(10)),
                            child: dataMap['avatarPath']!=null?Image.network(
                              MyServiceUrl.imgHeader + dataMap['avatarPath'],
                              width: 36.w,
                              height: 36.h,
                              fit: BoxFit.cover,
                            ):Image.asset("lib/Images/login/默认头像.jpeg",width: 36.w, height: 36.h, fit: BoxFit.cover,),
                          ),
                        ),
                        SizedBox(width: 8.w,),
                        Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [

                            Row(
                              children: [
                                Text(dataMap['realName'].toString(),style: TextStyle(color: Colors.black,fontSize: 13.sp),),
                                SizedBox(width: 4.h,),
                                BrnTagCustom(
                                  tagText: "信用"+(divideAndRound(dataMap['rating'], 20)).toString()+"星",
                                  backgroundColor: Color.fromRGBO(251, 236, 228, 1),
                                  textColor: MyColors.themeColor,
                                ),
                              ],
                            ),
                       
                            Text("交易  "+dataMap['totalNum'].toString()+"  "+"好评率  "+dataMap['rating']+"%"
                              ,style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
                     
                            Row(
                              children: [
                                Image.asset("lib/Images/OrderList/货源详情认证icon.png",width: 17.w,height: 17.h,),
                                Text("实名认证",style: TextStyle(color: Colors.black,fontSize: 12.sp),),
                                if(dataMap['category']==1)
                                  Row(
                                    children: [
                                      SizedBox(width: 9.w,),
                                      Image.asset("lib/Images/OrderList/货源详情认证icon.png",width: 17.w,height: 17.h,),
                                      Text("企业认证",style: TextStyle(color: Colors.black,fontSize: 12.sp),),
                                    ],
                                  ),
                              ],
                            ),

                          ],
                        ),

                      ],
                    ),

                  ],
                )
            ),
            onTap: (){
              Navigator.push( context, FadeRoute(page:ShipperIntroduction(
                shipperId:dataMap['shipperId'],
              )));

            },
          ),

        ],
      ),
      ),
          Container(
            padding: EdgeInsets.only(top: 15.h,left: 15.w,right: 15.w,bottom: 30.h),
            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(Radius.circular(10))),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                BrnSmallOutlineButton(
                  title: '联系货主',
                  textColor: MyColors.themeColor,
                  lineColor: MyColors.themeColor,
                  radius: 30,
                  width: 150.w,
                  onTap: () {

                    addDriverCantact();
                  },
                ),
                BrnSmallMainButton(
                  title: '立即抢单',
                  bgColor: MyColors.themeColor,
                  textColor: Colors.white,
                  width: 150.w,
                  radius: 30,
                  onTap: () {
                   preAdd();

                  },
                )
              ],
            ),
          )
      ],
      ),

    );
  }
}


class DespoitAlertShow extends StatefulWidget {
  const DespoitAlertShow({super.key, required this.despoitType});
  final int despoitType;
  @override
  State<DespoitAlertShow> createState() => _DespoitAlertShowState();
}

class _DespoitAlertShowState extends State<DespoitAlertShow> {


  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.all(Radius.circular(10))),
        width: 300.w,
        height: 280.h,
        child: Column(
          children: [
            SizedBox(height: 20.h,),
            widget.despoitType==1?
            Column(
              children: [
                Text("订金退还流程",style: TextStyle (color:Colors.black,fontSize:16.sp,decoration: TextDecoration.none),),
                Text("本单货源享有订金退还政策",style: TextStyle(fontSize: 11.sp,color: Color.fromRGBO(51, 51, 51, 0.5),decoration: TextDecoration.none),),
              ],
            ):
            Column(
              children: [
                Text("订金不退还流程",style:TextStyle (color:Colors.black,fontSize:16.sp,decoration: TextDecoration.none),),
                Text("本单货源享有订金支付后不退还",style: TextStyle(fontSize: 11.sp,color: Color.fromRGBO(51, 51, 51, 0.5),decoration: TextDecoration.none),),
              ],
            ),
            SizedBox(height: 17.h,),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Column(
                  children: [
                    Container(
                      width: 16.w,
                      height: 16.h,
                      child:  CircleAvatar(
                        radius: 30,
                        backgroundColor: MyColors.themeColor,
                        child: Text(
                          "1",
                          style: TextStyle(
                            fontSize: 12.sp,
                            color: Colors.white,
                          ),
                        ),
                      ),
                    ),
                    Container(color: Colors.black,width: 0.5.w,height: 15.h,),
                    Container(
                      width: 16.w,
                      height: 16.h,
                      child:  CircleAvatar(
                        radius: 30,
                        backgroundColor: MyColors.themeColor,
                        child: Text(
                          "2",
                          style: TextStyle(
                            fontSize: 12.sp,
                            color: Colors.white,
                          ),
                        ),
                      ),
                    ),
                    Container(color: Colors.black,width: 0.5.w,height: 15.h,),
                    Container(
                      width: 16.w,
                      height: 16.h,
                      child:  CircleAvatar(
                        radius: 30,
                        backgroundColor: MyColors.themeColor,
                        child: Text(
                          "3",
                          style: TextStyle(
                            fontSize: 12.sp,
                            color: Colors.white,
                          ),
                        ),
                      ),
                    ),

                  ],
                ),
                SizedBox(width: 8.w,),
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(widget.despoitType==1? "司机订货时支付订金到平台":"司机订货时支付订金到平台",style: TextStyle(color: Colors.black,decoration: TextDecoration.none,fontSize: 13.sp),),
                    SizedBox(height: 15.h,),
                    Text(widget.despoitType==1? "货主点击“确认收货”":"司机点击“已装货”",style: TextStyle(color: Colors.black,decoration: TextDecoration.none,fontSize: 13.sp),),
                    SizedBox(height: 15.h,),
                    Text(widget.despoitType==1? "平台将订金退还给司机":"平台将订金支付到货主钱包",style: TextStyle(color: Colors.black,decoration: TextDecoration.none,fontSize: 13.sp),),
                  ],
                ),
              ],
            ),
            SizedBox(height: 10.h,),
            widget.despoitType==1?
            Container(
              padding: EdgeInsets.only(left: 40.w,right: 40.w),

              child:  RichText(
                text: TextSpan(children: [

                  TextSpan(
                      text: "若您未点击'确认收货'，平台将在 ",
                      style: TextStyle(fontSize: 12.sp, decoration: TextDecoration.none,color: Colors.black54,)),
                  TextSpan(
                      text: '平台将在最晚装货时间7天内将订金退还',

                      style: TextStyle(fontSize: 12.sp,decoration: TextDecoration.none, color: MyColors.themeColor),
                      recognizer: TapGestureRecognizer()
                        ..onTap = () {
                          // 查看 服务条款
                        }),
                  TextSpan(
                      text: "给司机 ",
                      style: TextStyle(fontSize: 12.sp, decoration: TextDecoration.none,color: Colors.black54,)),
                ]),
              ),
            )
            : Container(
              padding: EdgeInsets.only(left: 40.w,right: 40.w),

              child:  RichText(
                text: TextSpan(children: [

                  TextSpan(
                      text: "若司机未点击”已装货“，平台将在 ",
                      style: TextStyle(fontSize: 12.sp, decoration: TextDecoration.none,color: Colors.black54,)),
                  TextSpan(
                      text: '最晚装货间24小时后将订金自动支付',

                      style: TextStyle(fontSize: 12.sp,decoration: TextDecoration.none, color: MyColors.themeColor),
                      recognizer: TapGestureRecognizer()
                        ..onTap = () {
                          // 查看 服务条款
                        }),
                  TextSpan(
                      text: "给货主 ",
                      style: TextStyle(fontSize: 12.sp, decoration: TextDecoration.none,color: Colors.black54,)),
                ]),
              ),
            ),

            SizedBox(height: 15.h,),

            Container(
              padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 5.h,bottom: 5.h),
              width: 280.w,
              decoration: BoxDecoration(
                  color:Color.fromRGBO(255, 244, 229, 1) ,
                  borderRadius: BorderRadius.all(Radius.circular(10))),

              child:  RichText(
                text: TextSpan(children: [

                  TextSpan(
                      text: '具体订金规则详情，请见 ',
                      style: TextStyle(fontSize: 12.sp, decoration: TextDecoration.none,color: Colors.black54,)),
                  TextSpan(
                      text: '《速配货平台订金担保规则》》',

                      style: TextStyle(fontSize: 12.sp,decoration: TextDecoration.none, color: MyColors.blueColor),
                      recognizer: TapGestureRecognizer()
                        ..onTap = () {
                          // 查看 服务条款
                        }),

                ]),
              ),
            ),

            TextButton(onPressed: (){
              Navigator.pop(context);
            }, child: Text("                   我知道了                   ",style: TextStyle(color: MyColors.themeColor,decoration: TextDecoration.none,fontSize: 16.sp
            ),)),
          ],
        ),
      ),
    );;
  }
}

class CarGoodsMessageTips extends StatefulWidget {
  const CarGoodsMessageTips({super.key});

  @override
  State<CarGoodsMessageTips> createState() => _CarGoodsMessageTipsState();
}

class _CarGoodsMessageTipsState extends State<CarGoodsMessageTips> {
  @override
  Widget build(BuildContext context) {
    return Center(
      child:Container(
        decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.all(Radius.circular(10))),
        width: 270.w,
        height: 200.h,
        padding: EdgeInsets.only(top:18.h,bottom: 11.h ),
        child: Column(
          children: [
            Text("温馨提示",style: TextStyle(color: Colors.black,fontSize: 16.sp,fontWeight: FontWeight.w600,decoration: TextDecoration.none),),
            SizedBox(height: 10.h,),
            Container(
              width: 222.w,
              child:  RichText(
                softWrap: true,
                text: TextSpan(
                  children: [
                    TextSpan(
                      text: '装货前请核查货物种类，勿承运危险货物、违禁货物，限运货物需有相应证明文件，否则您可能面临平台禁用账号、行政处罚、国家公诉等不利后果。具体详见法律公告页:',
                      style: TextStyle(color:Colors.black,fontSize: 13.sp),
                    ),
                    TextSpan(
                      text: '《关于速配货平台货物发布及承运规范的公告》',
                      style: TextStyle(color: MyColors.blueColor),
                      recognizer: TapGestureRecognizer()
                        ..onTap = () {

                        },
                    ),
                  ],
                ),
              ),
            ),
            Divider(height: 26.h,color: MyColors.backgreyColor,),
            GestureDetector(
              child: Text("            我知道了            ",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp,decoration: TextDecoration.none),),
                onTap: () {
                  Navigator.pop(context);
              }
            )

          ],
        ),
      ),
    );
  }
}
